﻿using System;
using System.IO;
using System.Net;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace APBR_Patch_Mirror
{
    public class Info
    {
        public static string APB_Path; // { get; set; }
        public static string filePath = "";
        public static string Patches = "Patches.xml";
        public static string ClientFiles = "ClientFiles.xml";
        public static string LauncherFiles = "LauncherFiles.xml";
        public static string CurrentMirror = null;
        public static string curExtract = null;
        public static string LocalC_Ver = null;
        public static string LocalL_Ver = null;
        public static string RemoteC_Ver = null;
        public static string RemoteL_Ver = null;
        public static string RemoteFile;
        public static string ClientFilesZip;
        public static string LauncherFilesZip;
        
        public static int integer = 0;
        public static read.LauncherSyncer LauncherXML;
        public static read.ClientSyncer ClientXML;
        public static string cver = "Client" + RemoteC_Ver + ".xml";
        public static string lver = "Launcher" + RemoteL_Ver + ".xml";
        public static string[] Webmirrors = null;
        public static string G1 = "http://apb.patch.gamersfirst.com/";

        public static void error(Exception e)
        {
            MessageBox.Show(null, e.ToString(), e.HelpLink);
            File.AppendAllText("Error.log", "________________________\n");
            File.AppendAllText("Error.log", DateTime.Now +"\n"+ e.ToString()+"\n\n");
            Environment.Exit(-1);
        }

        public static string ConvertPath(string path, bool BackSlash = false)
        {
            string[] temp = path.Split('\\', '/');
            string fullpath = null;
            if (BackSlash)
            {
                for (int i = 0; i < temp.Length; i++)
                {
                    if (fullpath == null) fullpath = fullpath + temp[i];
                    else fullpath = fullpath + Path.DirectorySeparatorChar + temp[i];
                }
            }
            else
            {
                for (int i = 0; i < temp.Length; i++)
                {
                    if (fullpath == null) fullpath = fullpath + temp[i];
                    else fullpath = fullpath + "/" + temp[i];
                }
            }
            return fullpath;
        }

    }

}
